import { Controller, Get, Post, Body, Patch, Param, Delete, Query } from "@nestjs/common";
import { ApiService } from "./api.service";
import { CreateApiDto } from "./dto/create-api.dto";
import { UpdateApiDto } from "./dto/update-api.dto";
import { ApiBearerAuth, ApiOperation, ApiTags } from "@nestjs/swagger";
import { FindAllDto } from "@/modules/system/api/dto/findAll.dto";

@Controller("system/api-scope")
@ApiBearerAuth()
@ApiTags("Api接口权限")
export class ApiController {
    constructor(private readonly apiService: ApiService) {
    }
    
    @Post()
    @ApiOperation({ summary: "更具menuId创建接口权限" })
    create(@Body() createApiDto: CreateApiDto) {
        return this.apiService.create(createApiDto);
    }
    
    @Get('findApiByMenuTree')
    @ApiOperation({ summary: "菜单下的接口权限列表树" })
    findApiByMenuTree() {
        return this.apiService.findApiByMenuTree();
    }
    
    @Get()
    @ApiOperation({ summary: "更具menuId获取接口权限列表" })
    findAll(@Query() findAllDto: FindAllDto) {
        return this.apiService.findAll(findAllDto);
    }
    
    @Get(":id")
    findOne(@Param("id") id: string) {
        return this.apiService.findOne(+id);
    }
    
    @Patch(":id")
    @ApiOperation({ summary: "更具id更新" })
    update(@Param("id") id: string, @Body() updateApiDto: UpdateApiDto) {
        return this.apiService.update(+id, updateApiDto);
    }
    
    @Delete(":id")
    @ApiOperation({ summary: "更具id删除" })
    remove(@Param("id") id: string) {
        return this.apiService.remove(+id);
    }
}
